package com.yc.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yc.model.Dishesinfo;
import com.yc.model.Userinfo;
import com.yc.service.DishesService;
import com.yc.service.UserService;

@Controller
public class IndexController
{
	@Autowired
	DishesService service;
	@Autowired
	UserService uservice;

	public DishesService getService() {
		return service;
	}

	public void setService(DishesService service) {
		this.service = service;
	}

	@RequestMapping(value="/index.action")
	public String IndexPage() {
		return "pages/index";
	}
	
	@RequestMapping(value="/logout.order")
	public String logout() {
		return "pages/login";
	}
	
	@RequestMapping(value="/modifymyinfo.order")
	public String modyfyUser() {
		return "pages/main/users/modifyuser";
	}
	//显示用户
	@RequestMapping(value="/touseradmin.order")
	public String touseradmin() {
		return "pages/main/admin/useradmin";
	}
	
	@RequestMapping(value="/towaitermain.order")
	public String towaitermain() {
		return "pages/main/waiters/takeorder";
	}
	
	@RequestMapping(value="/topaylist.order")
	public String topaylist() {
		return "pages/main/waiters/paylist";
	}
	//添加用户
	@RequestMapping(value="/toadd.order")
	public String addUser() {
		return "pages/main/admin/adduser";
	}
	//显示菜单,
	@RequestMapping(value="/todishesadmin.order")
	public String todishesadmin() {
		return "pages/main/admin/dishesadmin";
	}
	//添加菜单
	@RequestMapping(value="/toadddishes.order")
	public String addCaidan() {
		return "pages/main/admin/adddishes";
	}
	//结算界面
	@RequestMapping(value="/toadminmain.order")
	public String toadminmain() {
		return "pages/main/admin/main";
	
	}
	//查看数据界面
	@RequestMapping(value="/tooperatedata.order")
	public String tooperatedata() {
		return "pages/main/admin/operatedata";
		
	}
	//编辑菜单修改跳转
		@RequestMapping("/tomodifydishes.order")
		public String toModifyDishes(HttpServletRequest request,
				HttpServletResponse response, Integer dishesId) {

			// 获取要修改的菜品ID并查询对应的菜品信息
			Dishesinfo info = service.getDishesById(dishesId);
			// 将菜品信息加入request作用域
			request.setAttribute("DISHES_INFO", info);
			return "pages/main/admin/modifydishes";
		}
		//查看在在线厨师
		@RequestMapping(value="/toonlinewaiters.order")
		public String onlinewaiters() {
			return "pages/main/admin/onlinewaiters";
			
		}
		
		//用户修改信息
		@RequestMapping("/tomodifyuser.order")
		public String tomodifyuser(HttpServletRequest request,
				HttpServletResponse response, Integer userId) {
			Userinfo info = uservice.getUserById(userId);
			request.getSession().setAttribute("MODIFY_INFO", info);
			return "pages/main/admin/modifyuser";
		}
}
